﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;

namespace DARE
{
    public class CButtonData : CWidgetData
    {
        public CHudTextureData clickedTexture;
        public CHudTextureData releasedTexture;

        public override void FillDataStructure(CWidget wid)
        {
            CButton w = wid as CButton;
            base.FillDataStructure(wid);
            if (w.ClickedTexture != null)
            {
                clickedTexture = new CHudTextureData();
                clickedTexture.FillDataStructure(w.ClickedTexture);
            }
            if (w.ReleasedTexture != null)
            {
                releasedTexture = new CHudTextureData();
                releasedTexture.FillDataStructure(w.ReleasedTexture);
                texture = releasedTexture;
            }
        }

        public override void FillFromDataStructure(ref CWidget wid, CHUDSystem hud)
        {
            base.FillFromDataStructure(ref wid, hud);
            if (clickedTexture != null)
            {
                CHudTexture tex = new CHudTexture();
                clickedTexture.FillFromDataStructure(tex);
                (wid as CButton).ClickedTexture = tex;
            }
            if (releasedTexture != null)
            {
                CHudTexture tex = new CHudTexture();
                releasedTexture.FillFromDataStructure(tex);
                (wid as CButton).ReleasedTexture = tex;
                wid.Texture = (wid as CButton).ReleasedTexture;
            }
        }
    }
}
